package no.nordicsemi.android.nrfmesh.database.entity;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

import java.io.Serializable;

@Entity(tableName = "sent_profiles")
public class SentProfile implements Serializable{

    @PrimaryKey(autoGenerate = true)
    public int id;

    public int segmentDuration;   // 段时长（ms）
    public String waveformType;   // 波形类型（正弦波、方波等）
    public int pulseWidth;        // 脉宽（μs）
    public int frequency;         // 频率（Hz）
    @ColumnInfo(name = "segment_index")
    public int segmentIndex;
    @ColumnInfo(name = "group_id")
    public String groupId;        // 组ID，用于将多段参数分组
    @ColumnInfo(name = "config_name")
    public String configName;     // 配置名称
    public int totalSegment;      // 原为 char[]，改为 int 以便 Room 持久化
    public int currentBlock;      // 原为 char[]，改为 int 以便 Room 持久化


    @Override
    public String toString() {
        return "SentProfile{" +
                "id=" + id +
                ", segmentDuration=" + segmentDuration +
                ", waveformType='" + waveformType + '\'' +
                ", pulseWidth=" + pulseWidth +
                ", frequency=" + frequency +
                ", segmentIndex=" + segmentIndex +
                ", groupId='" + groupId + '\'' +
                ", configName='" + configName + '\'' +
                '}';
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SentProfile that = (SentProfile) o;

        return segmentDuration == that.segmentDuration &&
                waveformType.equals(that.waveformType) &&
                pulseWidth == that.pulseWidth &&
                frequency == that.frequency &&
                segmentIndex == that.segmentIndex &&
                (groupId != null ? groupId.equals(that.groupId) : that.groupId == null) &&
                (configName != null ? configName.equals(that.configName) : that.configName == null);
    }

    @Override
    public int hashCode() {
        int result = segmentDuration;
        result = 31 * result + waveformType.hashCode();
        result = 31 * result + pulseWidth;
        result = 31 * result + frequency;
        result = 31 * result + segmentIndex;
        result = 31 * result + (groupId != null ? groupId.hashCode() : 0);
        result = 31 * result + (configName != null ? configName.hashCode() : 0);
        return result;
    }
}
